export default {
  data() {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
    };
  },
  methods: {
    changeRadio(e, data) {
      if (e === '1') {
        this.form[data.inputModel] = '';
        this.form[data.imgProps] = [];
        this.form[data.showImg] = [];
      }
    },
    handleSuccess(res, props) {
      this.form[props].push(res);
    },
    beforeUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 10;

      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 10MB!');
      }
      return isLt2M;
    },
    handleRemove(file, fileList, props) {
      this.form[props] = JSON.parse(JSON.stringify(fileList));
    },
    handlePreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleExceed() {
      this.$message.error('最多上传五张');
    },
  },
};
